package com.tjh.spring5.testdemo;

import com.tjh.spring5.config.SpringConfig;
import com.tjh.spring5.service.UserService1;
import com.tjh.spring5.service.UserService2;
import com.tjh.spring5.service.UserService3;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Create by koala on 2021-02-16
 */
public class TestSpring5Day19 {

    //day19
    @Test
    public void testService1() {
        ApplicationContext context
                = new ClassPathXmlApplicationContext("beanday19.xml");
        UserService1 userService = context.getBean("userService1", UserService1.class);
        System.out.println(userService);
        userService.add();
    }

    //day21
    @Test
    public void testService2() {
        ApplicationContext context
                = new ClassPathXmlApplicationContext("beanday19.xml");
        UserService2 userService = context.getBean("userService2", UserService2.class);
        System.out.println(userService);
        userService.add();
    }

    //day22
    @Test
    public void testService3() {
        ApplicationContext context
                = new ClassPathXmlApplicationContext("beanday19.xml");
        UserService3 userService = context.getBean("userService3", UserService3.class);
        System.out.println(userService);
        userService.add();
    }

    //day23
    @Test
    public void testService4() {
        //加载配置类
        ApplicationContext context
                = new AnnotationConfigApplicationContext(SpringConfig.class);
        UserService3 userService = context.getBean("userService3", UserService3.class);
        System.out.println(userService);
        userService.add();
    }

}
